home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 6 / MacMania 6.toast / / Multimedia & Desktop / sk8 / SK8InJava / Code / Devices / SK8TextStream.java < prev   
Encoding:
Java Source  |  1997-02-27  |  1.4 KB  |  63 lines  |  [TEXT/CWIE]

  1. /*  SK8 © 1997 Apple Computer, Inc.
  2.     This code is protected under the current SK8 License
  3.     See http://sk8.research.apple.com/ for more information
  4.     Apple Research Laboratories
  5. */
  6.  
  7.  
  8. import java.io.*;
  9.  
  10.  
  11. public class textstream extends stream {
  12.     
  13.     // reading
  14.     
  15.     public final char readcharacter() throws IOException{
  16.         if (!mDirection.equals("input")){
  17.             throw new IOException ("can only read from input streams");
  18.         } else {
  19.             if (mInDataStream == null)
  20.                 setupStreams();
  21.                 
  22.             return mInDataStream.readChar();
  23.         }
  24.     }
  25.  
  26.     
  27.     public final String readline() throws IOException{
  28.         if (!mDirection.equals("input")){
  29.             throw new IOException ("can only read from input streams");
  30.         } else {
  31.             if (mInDataStream == null)
  32.                 setupStreams();
  33.                 
  34.             return mInDataStream.readLine();
  35.         }
  36.     }
  37.  
  38.  
  39.     //writing
  40.     
  41.     public final void writecharacter(char ch) throws IOException{
  42.         if (!mDirection.equals("output")){
  43.             throw new IOException ("can only write to output streams");
  44.         } else {
  45.             if (mOutDataStream == null)
  46.                 setupStreams();
  47.                 
  48.             mOutDataStream.writeChar(ch);
  49.         }
  50.     }
  51.  
  52.  
  53.     public final void writestring(String str) throws IOException{
  54.         if (!mDirection.equals("output")){
  55.             throw new IOException ("can only write to output streams. This stream is " + mDirection );
  56.         } else {
  57.             if (mOutDataStream == null)
  58.                 setupStreams();
  59.                 
  60.             mOutDataStream.writeChars(str);
  61.         }
  62.     }
  63. }